const axios = require('axios')
const path = require('path')
const fs = require('fs')
const ws = fs.createWriteStream('./baidu1.html',{encoding:'utf-8'})
axios.get('https://baidu.com').then(res => {
    ws.write(res.data, function(err){
        if(!err){
            console.log('写入成功')
        }
    })
    ws.close(function(){
        ws.end()
    })
})

fs.unlink(path.resolve(__dirname, './baidu1.html'), function(err){
    if(!err){
        console.log('删除成功')
    }else{
        console.log(err)
    }
})